using System;
using NobleTech.Products.CreatureKingdom.Utils;
using System.Collections.Generic;

namespace NobleTech.Products.CreatureKingdom
{
    public class World
    {
        private uint time = 0;

        private TopQuadrant topQuadrant;

        public World()
        {
            this.topQuadrant = new TopQuadrant(new RectangleD(new PointD(5000, 5000), 100));
        }

        public void AddOrganism(Type implementationType)
        {
            PointD location = new PointD(
                WorldStats.RandomGenerator.Next((int)topQuadrant.Area.Left, (int)topQuadrant.Area.Right),
                WorldStats.RandomGenerator.Next((int)topQuadrant.Area.Top, (int)topQuadrant.Area.Bottom));
            topQuadrant.AddOrganism(new Organism(Guid.NewGuid(), implementationType, location));
        }

        public ViewPort GetViewPort(RectangleD bounds)
        {
            return topQuadrant.GetViewPort(bounds);
        }

        public void DoMove()
        {
            ++time;
            topQuadrant.GetMove();
            topQuadrant.UpdateInfo();
            topQuadrant.DoInteraction();
            topQuadrant.DoMove();
            topQuadrant.DoLifeEvents();
        }
    }
}
